package com.nba.dao.impl;

import java.util.List;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import com.nba.bean.Type;
import com.nba.dao.TypeDao;
import com.nba.util.DBUtil;

public class TypeDaoImpl implements TypeDao {
	
	JdbcTemplate jt = new JdbcTemplate(DBUtil.getDataSource());
	
	@Override
	public Type selectTypeByName(String typeName) {
		String sql = "SELECT * FROM type WHERE type_name = ?";
		List<Type> list = jt.query(sql, new BeanPropertyRowMapper<Type>(Type.class),typeName);
		if(list.size() == 0) {
			return null;
		}else {
			return list.get(0);
		}
	}

}
